react-querystring-router
Bare router for React components, using query string as props.
http://mysite.com/?component=Father&eyes=blue&mood=happy
This route will render the component class returned by getComponentClass
using the following props:
{
component: 'Father',
eyes: 'blue',
mood: 'happy'
}
Options
var Router = require('react-querystring-router').Router;
var myRouter = new Router({
defaultProps: {
fries: true
},
getComponentClass: function(props) {
return require('components/' + props.component + '.jsx');
},
container: document.getElementById('content'),
onChange: function(props) {
}
});
The router always sends a reference to itself to the rendered component through
the router
prop.
Changing the route
var stringifyParams = require('react-querystring-router').uri.stringifyParams;
render: function() {
return <div className="serious-component">
<a href={stringifyParams({lifeChangingProp: 1})}
onClick={this.props.router.routeLink}>
Click me por favor
</a>
</div>;
};